function [phi,phi_x,phi_y,phi_xx,phi_xy,phi_yy] = fe_basis_bb(d, x ,y, desc)
% function [phi,phi_x,phi_y,phi_xx,phi_xy,phi_yy] = fe_bb(d, x ,y, desc)
% this funtion return the value of shape functions of degree d at points v
%    d ------ degree , must be positive integer
%    x and y is the corresponding value of L1 and L2 
% the derivtive must be comput with relate to the jacobi of element
%    2
%    |   \
%    |      \
%    |         \
%    3 ------ 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

L1 = x;
L2 = y;
L3 = 1-x-y;

phi = vdm23(d,L1,L2,L3);

% first derivatives on master elements
Id = diag(ones((d+1)*(d+2)/2,1));
u = d*de_cast_step(Id,d,1,0,-1,desc);  % direction derivetives
v = d*de_cast_step(Id,d,0,1,-1,desc);

Mat = vdm23(d-1,L1,L2,L3);  % low order vdm
phi_x = Mat*u;  %get the deriv B-form value
phi_y = Mat*v;

% second derivatives on master elements
uu = (d-1)*de_cast_step(u,d-1,1,0,-1,desc);
uv = (d-1)*de_cast_step(u,d-1,0,1,-1,desc);
vv = (d-1)*de_cast_step(v,d-1,0,1,-1,desc);

Mat = vdm23(d-2,L1,L2,L3);  % low order vdm
phi_xx = Mat*uu;  %get the deriv B-form value
phi_xy = Mat*uv;
phi_yy = Mat*vv;

end